// pages/basics/search/search.js
// pages/basics/home/index.js
var util = require('../../../utils/util.js')
var wxRequest = require('../../../utils/wxRequest.js')
var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    page:1,
    content:'',
    picList:[],
    stopLoadMoreTiem:false,
    
    showModal:false,
    showName:'aa',
    showIngImg:'https://static.ath365.com/Frj0tYNZdiEK4ZgJQsVocDsnZgDn'
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },
  valuechange:function(e){
    this.data.content = e.detail.value;
    console.log(this.data.content);
    //var content = e.detail.value;
    //this.setData({content:content});
  },
  showTip:function (e) {
    var id = e.currentTarget.id,
    url = '/pages/basics/detail/detail?id=' + id;
    wx.navigateTo({
      url: url
    })
  },
  //上拉
  lower:function(){
    var that = this;
    console.log("lower");
    if (that.stopLoadMoreTiem) {
      return;
    }
    this.setData({
      page: this.data.page + 1 //上拉到底时将page+1后再调取列表接口
    });
    this.gosearch();
  },
  search:function(){
    this.data.picList = [];
    this.gosearch();
  },
  gosearch:function(e){
    var that = this;
    var data = {
      page:that.data.page,
      content:that.data.content
    };
    var res = util.searchList(data);
      res.then(function(json){
            that.setData({
              picList:that.data.picList.concat(JSON.parse(json.data.result)),
            });
            that.stopLoadMoreTiem = false;
      });
  },
  preventHide:function(e){
    this.setData({showModal:false});
  },
  showTip:function (e) {
    var id = e.currentTarget.id,
    title = e.currentTarget.dataset.name,
    img = e.currentTarget.dataset.path;

    this.setData({
      showIngImg:img,
      showName:title,
      showModal:true
    });
  },
  // 禁止屏幕滚动
  preventTouchMove:function () {
  }
})